from rest_framework import serializers
from .models import NewsTag, News, NewsComment
from app.authPro.serializers import UserSerializer


class NewsTagSerializer(serializers.ModelSerializer):
    class Meta:
        model = NewsTag
        fields = ("id", "name")


class NewsSerializer(serializers.ModelSerializer):
    tag = NewsTagSerializer()
    author = UserSerializer()

    class Meta:
        model = News
        fields = ('id', 'title', 'desc', 'pub_time', 'thumbnail_url', 'is_delete', 'tag', 'author')


class NewsCommentSerializer(serializers.ModelSerializer):
    author = UserSerializer()

    class Meta:
        model = NewsComment
        fields = ('content', 'pub_time', 'author')
